package com.example.lib_http
import okhttp3.Interceptor
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.create
import java.util.concurrent.TimeUnit

private val client by lazy {
    OkHttpClient.Builder()
        .connectTimeout(30,TimeUnit.SECONDS)
        .readTimeout(30,TimeUnit.SECONDS)
        .writeTimeout(30,TimeUnit.SECONDS)
        .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
        .addInterceptor(HttpInterceptor())
        .build()
}
val retrofit by lazy {
    Retrofit.Builder()
        .baseUrl("http://10.161.9.80:2207")
        .client(client)
        .addConverterFactory(GsonConverterFactory.create())
        .build()
}
inline fun <reified T> getService()= retrofit.create(T::class.java)